define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'orderdownload/index' + location.search,
                    // add_url: 'orderdownload/add',
                    edit_url: 'orderdownload/edit',
                    // del_url: 'orderdownload/del',
                    // multi_url: 'orderdownload/multi',
                    // import_url: 'orderdownload/import',
                    table: 'order',
                }
            });
            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [

                        {checkbox: true},
                        {field: 'order_id', title: __('Order_id'), operate: 'LIKE'},
                        {field: 'platform_type', title: __('Platform_type'), searchList: {"1":__('Platform_type 1'),"2":__('Platform_type 2'),"3":__('Platform_type 3'),"4":__('Platform_type 4'),"5":__('Platform_type 5')}, formatter: Table.api.formatter.status},
                        {field: 'phone', title: __('Phone'), operate: 'LIKE'},
                        {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'call_image', title: __('通话记录'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'audit_upload_time', title: __('Audit_upload_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'is_agency', title: __('Is_agency'), searchList: {"1":__('Is_agency 1'),"2":__('Is_agency 2')}, formatter: Table.api.formatter.normal},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]

                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },

        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
